﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using 聚欣订单分析.Ling;
using System.Collections.Generic;
using 聚欣订单分析.PublicClass;

namespace 聚欣订单分析
{
    public partial class login : System.Web.UI.Page
    {
        PLSQLClass pl = new PLSQLClass();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.Title = " 综合业务系统-登录";
            }
        }



        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string strName = LoginID.Text.Trim();
            string strPwd = LoginPWD.Text.Trim();
            if (strName == "" || strPwd == "")
            {
                ErrMessage.Text = "用户名密码不能为空!";
                return;
            }
            List<tbl_user> d = null;
            using (tbl_userDataContext userData = new tbl_userDataContext())
            {
                d = userData.tbl_user.Where(p => p.UserName == strName && p.pwd == strPwd).ToList();
            }
            if (d.Count == 0)
            {
                ErrMessage.Text = "用户名密码错!";
                return;
            }
            Session["UserID"] = d[0].ID;
            Session["UserName"] = d[0].UserName;
            Session["realname"] = d[0].realname;
            Session["qx"] = d[0].qx;
            Session["qy"] = d[0].qy;
            Session["qtqx"] = d[0].qtqx;
            pl.SqlGetData("INSERT INTO [tbl_Log] VALUES('"+ d[0].UserName + "','"+ d[0].realname + "',getdate(),'登录')");
            Response.Redirect("index.aspx");
        }
    }
}
